package com.google.code.pokerstats_service;
import java.util.Date;

import javax.jdo.annotations.IdGeneratorStrategy;
import javax.jdo.annotations.PersistenceCapable;
import javax.jdo.annotations.IdentityType;
import javax.jdo.annotations.Persistent;
import javax.jdo.annotations.PrimaryKey;

/**
 * A single game.
 *  
 * @author DL
 */
@PersistenceCapable(identityType = IdentityType.APPLICATION)
public class Game {
    /** @see Object#equals */
    @Override
    public boolean equals(Object obj) {
        if (obj == null) {
            return false;
        }
        if (getClass() != obj.getClass()) {
            return false;
        }
        final Game other = (Game) obj;
        return (id == other.id);
    }
    
    /** @see Object#hashCode */
    @Override
    public int hashCode() {
        if (id != null) {
            return id.intValue();
        }
        return super.hashCode();
    }
    
    /** @see Object#toString */
    @Override
    public String toString() {
        return id + "," + groupId + "," + date.getTime();
    }
    
    /** The game's unique id. */
    @PrimaryKey
    @Persistent(valueStrategy = IdGeneratorStrategy.IDENTITY)
    public Long id;

    /** The relevant group's unique id. */
    @Persistent
    public Long groupId;

    /** The game's date. */
    @Persistent
    public Date date;
}
